package it.stasbranger.myproject.client.managed.activity;

import com.google.gwt.place.shared.Place;
import com.google.gwt.place.shared.PlaceController;

import com.google.gwt.requestfactory.shared.Receiver;
import com.google.gwt.requestfactory.shared.Request;

import com.google.gwt.view.client.Range;

import it.stasbranger.myproject.client.managed.request.ApplicationRequestFactory;

import java.util.List;

/**
 * Activity that requests and displays all Requestss.
 */
public class RequestsListActivity extends it.stasbranger.myproject.client.scaffold.place.AbstractProxyListActivity<it.stasbranger.myproject.client.managed.request.RequestsProxy>
		implements
		it.stasbranger.myproject.client.scaffold.activity.IsScaffoldMobileActivity {

	private final ApplicationRequestFactory requests;

	public RequestsListActivity(ApplicationRequestFactory requests, it.stasbranger.myproject.client.scaffold.place.ProxyListView<it.stasbranger.myproject.client.managed.request.RequestsProxy> view, PlaceController placeController) {
		super(placeController, view, it.stasbranger.myproject.client.managed.request.RequestsProxy.class);
		this.requests = requests;
	}

	public Place getBackButtonPlace() {
		return it.stasbranger.myproject.client.scaffold.ScaffoldMobileApp.ROOT_PLACE;
	}

	public String getBackButtonText() {
		return "Entities";
	}

	public Place getEditButtonPlace() {
		return null;
	}

	public String getTitleText() {
		return "Requests";
	}

	public boolean hasEditButton() {
		return false;
	}

	protected Request<List<it.stasbranger.myproject.client.managed.request.RequestsProxy>> createRangeRequest(Range range) {
		return requests.requestsRequest().findAllRequestss(range.getStart(), range.getLength());
	}

	protected void fireCountRequest(Receiver<Integer> callback) {
		requests.requestsRequest().countRequestss().fire(callback);
	}
}
